const express = require('express')
const app = express()
const body_paser = require('body-parser')

const url = require('url')

app.use(body_paser.urlencoded({extended:false}))

app.listen(65535,()=>{
    console.log('Server')
})

app.use(express.static('./www'))

app.get('*',(req,res,next)=>{
    if(req.url == '/index.html'){
        res.send('文件内容')
    }else{
        console.log('下一步')
        next()
    }
})

app.get('/index',(req,res,next)=>{
    if(url.parse(req.url).path == '/favicon.ico'){
        return
    }
    console.log(req.query)
    
    console.log(req.method + '来了')
    res.send(req.method + '过来的吧')
})

app.post("/index",(req,res,next)=>{
    // console.log(req.query)
    console.log(req.body)
    
    console.log(req.method + '来了')
    res.send(req.method + '过来的吧')
})

app.all('/abc',(req,res,next)=>{
    console.log(req.method)
    res.send(req.method)
})
//按从上到下先后顺序来决定执行哪个功能